import * as actionTypes from "./constants";
import {
    gitDetails, findNewVoteArtistList, selectNewsList

} from "../../../services/home";

const changeDetailsAction = (res) => ({
    type: actionTypes.GET_DETAILS,
    details: res.data,
});
const changeArtiList = (res) => ({
    type: actionTypes.GET_ARTILIST,
    artiList: res.data,
});
const changeReport = (res) => ({
    type: actionTypes.GET_REPORT,
    reportList: res.data,
});
const changeLook = (res) => ({
    type: actionTypes.GET_LOOK,
    lookList: res.data,
});


export const getDetailsAction = (data) => {
    return (dispatch) => {
        gitDetails(data).then((res) => {
            res.data.banner = 'http://fastdfs.cbda1984.com/' + res.data.banner
            if (res.data.rightContent) {
                res.data.rightContent = JSON.parse(res.data.rightContent)
            }
            dispatch(changeDetailsAction(res));
        });
    };
};
export const getArtiList = (data) => {
    return (dispatch) => {
        findNewVoteArtistList(data).then((res) => {
            dispatch(changeArtiList(res));
        });
    };
};
export const getReport = (data) => {
    return (dispatch) => {
        selectNewsList(data).then((res) => {
            dispatch(changeReport(res));
        });
    };
};
export const getLook = (data) => {
    return (dispatch) => {
        selectNewsList(data).then((res) => {
            dispatch(changeLook(res));
        });
    };
};

